<?php

if (!defined('IN_ADMIN')) {
    exit('Access Denied');
}

$mpurl = 'admin.php?ac=send_message';
$list = array();
if ($_GET ['op'] == "sendMessages") {
    $uid      = intval($_POST ['uid']);
    $mUidsStr = strval($_POST['mUidsStr']);
    $mUids    = explode(",", $mUidsStr);
    $messageContent  = getstr($_POST['content'], 512);
    if ($uid < 1 || count($mUids) < 1 || empty($messageContent)){
        $msg = "参数非法!";
        cpmessage($msg);
        return FALSE;
    }
    
    $num = 0;
    foreach ($mUids as $value){
        $param = array(
                'do'       => 'adminSendMessage',
                'format'   => 'json',
                'uid'      => $uid,
                'mUid'     => $value,
                'content'  => $messageContent,
        );
        
        $content = get_api_content($_SC ['apiurl'], $param);
        $content = json_decode($content);
        if ($content->resultData){
            $num ++;
        }
    }
    if ($num > 0){
        $msg = "成功发送<".$num.">条通知!";
    }else{
        $msg = "发送失败!";
    }

    cpmessage($msg);
}